//
//  ModelViewController.m
//  Drops
//
//  Created by SHG on 16/5/20.
//  Copyright © 2016年 Drops.er. All rights reserved.
//

#import "ModelViewController.h"



@interface ModelViewController ()

@end

@implementation ModelViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor whiteColor];
//    self.navigationController.navigationBar.barTintColor = Z_REDCOLOR;
    self.navigationController.navigationBar.barTintColor = Z_BLUECOLOR;
    
}

- (void)getRequestWithString:(NSString *)urlStr success:(void (^)(id))success {
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager GET:urlStr parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"加载错误:%@", error);
        //        UIAlertController *alert = [[UIAlertController alloc] init];
        [self showAlert:@"数据获取失败"];
    }];
}

- (void)timerFireMethod:(NSTimer *)theTimer {
    UIAlertView *promptAlert = (UIAlertView *)[theTimer userInfo];
    [promptAlert dismissWithClickedButtonIndex:0 animated:NO];
    promptAlert = NULL;
}

- (void)showAlert:(NSString *)_message {
    UIAlertView *prompAlert = [[UIAlertView alloc] initWithTitle:@"注意" message:_message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
    [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(timerFireMethod:) userInfo:prompAlert repeats:YES];
    [prompAlert show];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
